package com.aner.test.controller;
import com.aner.tester.controller.BaseControllerTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.aner.tester.utils.text.StringUtils;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;


/**
 * PostTestControllerTest class
 * 
 * @author aner
 * @date 2020-12-30
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@AutoConfigureMockMvc
public class PostTestControllerTest extends BaseControllerTest
{

    @Test
    public void testTest() {
        String params = "{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-30 13:39:01','doubleTest':0.7539474837760215,'floatTest':0.057317853,'intTest':0,'longTest':3,'stringTest':'猫0猪'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.post("/test/", jsonStr);
        
    }
    @Test
    public void testRequestParamDateTest() {
        String params = "{'testDate':'2020-12-30 13:39:02'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.post("/testRequestParamDate/", jsonStr);
        
    }
    @Test
    public void testRequestBodyDateTest() {
        String params = "1609306742105";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.postBody("/testRequestBodyDate/", jsonStr);
        
    }
    @Test
    public void testRequestBodyListTest() {
        String params = "['32狗','广5','的四']";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.postBody("/testRequestBodyList/", jsonStr);
        
    }
    @Test
    public void testRequestParamListTest() {
        String params = "{'testList':['5个事5个四','尔猪小的5安']}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.post("/testRequestParamList/", jsonStr);
        
    }
    @Test
    public void testRequestBodyMapTest() {
        String params = "{'尔11公':'173','告猫':'340558'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.postBody("/testRequestBodyMap/", jsonStr);
        
    }
    @Test
    public void testRequestBodyLongTest() {
        String params = "0";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.postBody("/testRequestBodyLong/", jsonStr);
        
    }
    @Test
    public void testPathVariableTest() {
        String params = "{'params':['个第小4猫','狗小','省猪小个猫','猪的小2','小事小猪','小公小'],'id':[2,2,2,3]}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.post("/testPathVariable/{params}/{id}", jsonStr);
        
    }
    @Test
    public void testDateTest() {
        String params = "{'test':'2020-12-30 13:39:02'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.post("/testDate/", jsonStr);
        
    }
    @Test
    public void testBodyTest() {
        String params = "{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.6197654925733068,'floatTest':0.63077796,'intTest':0,'longTest':0,'strArray':['小省三安3告','狗猫','故5狗四第','3狗猪5','个0','三小4个广'],'stringList':['小故','小3的小狗5','的的个东','小0个狗故猪','广个3'],'stringTest':'猫司四小小','testObjectArray':[{'booleanTest':true,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.4313350831214635,'floatTest':0.11143744,'intTest':1,'longTest':0,'stringTest':'东广'},{'booleanTest':true,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.19055504692486525,'floatTest':0.25869685,'intTest':1,'longTest':1,'stringTest':'1司的'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.38013418385471065,'floatTest':0.45297414,'intTest':0,'longTest':1,'stringTest':'小52广1公'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.6765854725300859,'floatTest':0.49240577,'intTest':1,'longTest':2,'stringTest':'2小'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.7970367537228564,'floatTest':0.8524487,'intTest':1,'longTest':3,'stringTest':'第安省小'},{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.4721447380048718,'floatTest':0.7600011,'intTest':1,'longTest':1,'stringTest':'的小4第'}],'testObjectList':[{'booleanTest':true,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.5187351287285499,'floatTest':0.67706,'intTest':1,'longTest':0,'stringTest':'广事'},{'booleanTest':true,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.8624257395935025,'floatTest':0.5012977,'intTest':1,'longTest':0,'stringTest':'的0小省省四'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.17794697613544375,'floatTest':0.002352059,'intTest':0,'longTest':1,'stringTest':'告猪的猪'},{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.3756393089324124,'floatTest':0.035780787,'intTest':0,'longTest':1,'stringTest':'小0故尔5小'}],'testObjectMap':{'安省的40小':'266','安狗小小三广':'706','狗狗故猫的':'806','告东尔猪':'22'}}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.postBody("/testRequestBody/", jsonStr);
        
    }
}
